package com.leete;







import com.oreilly.servlet.Base64Decoder;
import sun.misc.BASE64Decoder;

import java.io.*;

/**
 * @author liqiang
 * @version 1.0
 * @description:
 * @date 2023/5/17 16:11
 */
public class Test {

    public static void main(String[] args) throws IOException {

        FileReader reader = new FileReader(new File("C:\\Users\\leete\\Desktop\\base64.txt"));
        StringBuilder stringBuilder = new StringBuilder();
        char[] buffer = new char[100];
        int size;
        while ((size = reader.read(buffer)) != -1) {
            stringBuilder.append(buffer, 0, size);
        }

        BASE64Decoder base64Decoder = new BASE64Decoder();
        byte[] decodedBytes = base64Decoder.decodeBuffer(stringBuilder.toString());
        FileOutputStream fos = new FileOutputStream("output.pdf");
        fos.write(decodedBytes);
        fos.close();
    }

}
